﻿using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using AFDS.BusinessLogic;
using AFDS.BusinessLogic.Helpers;

namespace AFDS.Controls
{
    public class AddSiteControl : UserControl
    {
        private Category selCategory;
        private Button btn;
        private Label lbl_title;
        private Label lbl_url;
        private Label lbl_desc;
        private Label lbl_name;
        private Label lbl_email;
        private TextBox txt_title;
        private TextBox txt_url;
        private TextBox txt_desc;
        private TextBox txt_name;
        private TextBox txt_email;

        protected override void OnInit(EventArgs e)
        {
            setObjs();
            btn.Click += new EventHandler(btn_Click);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                ProcessQuerystrings();
        }

        private void ProcessQuerystrings()
        {
            if (!String.IsNullOrEmpty(Request.QueryString["cattoadd"]))
            {
                Guid gCatId = new Guid(Request.QueryString["c"].ToString());
                using (CategoryHelper hCat = new CategoryHelper())
                {
                    selCategory = hCat.Load(gCatId);
                    Response.Write("Selected Category: " + selCategory.Id.ToString());
                }
            }
        }

        private void setObjs()
        {
            btn = (Button)this.FindControl("btn_send");
            lbl_title = (Label)this.FindControl("lbl_title");
            lbl_url = (Label)this.FindControl("lbl_url");
            lbl_desc = (Label)this.FindControl("lbl_desc");
            lbl_name = (Label)this.FindControl("lbl_name");
            lbl_email = (Label)this.FindControl("lbl_email");
            txt_title = (TextBox)this.FindControl("txt_title");
            txt_url = (TextBox)this.FindControl("txt_url");
            txt_desc = (TextBox)this.FindControl("txt_desc");
            txt_name = (TextBox)this.FindControl("txt_name");
            txt_email = (TextBox)this.FindControl("txt_email");
        }

        void btn_Click(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    }
}
